<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>培训方案管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		function TrainprogramAttribute(attribute){
			$.ajax({
				type: "POST",
				url: "${ctx}/resource/resourceTrainprogram/findListByAttribute",
				data: {
					attribute:attribute.options[attribute.selectedIndex].value
				},
				success:function(json){
					$(".resetDuallist").empty();
					var list = json.dataObj;
					for(var i=0;i<list.CourseSystemList.length;i++)
					{
						$("#coursesystemIds").append("<option value='"+ list.CourseSystemList[i].id+"'>"+list.CourseSystemList[i].coursesystemName+"</option>");
					}
					for(var j=0;j<list.CtfSetList.length;j++)
					{
						$("#ctfSetIds").append("<option value='"+ list.CtfSetList[j].id+"'>"+list.CtfSetList[j].ctfSetName+"</option>");
					}
					for(var t=0;t<list.PaperList.length;t++)
					{
						$("#paperIds").append("<option value='"+ list.PaperList[t].id+"'>"+list.PaperList[t].paperName+"</option>");
					}
					$(".resetDuallist").bootstrapDualListbox('refresh');
				},
				error:function(){
					alertx("error");
				}
			});
		}

		function checkValidate() {
			var trainprogramName = document.getElementById("trainprogramName").value;
			var trainprogramAttribute = document.getElementById("trainprogramAttribute").value;
			var coursesystemIds = document.getElementById("coursesystemIds").value;
			var ctfSetIds = document.getElementById("ctfSetIds").value;
			var paperIds = document.getElementById("paperIds").value;


			//判断是否为空
			if (trainprogramName == "" || trainprogramName == null) {
				window.alertx("请输入培训方案名称！");
				return false;
			}
			if (trainprogramAttribute == "" || trainprogramAttribute == null) {
				window.alertx("请选择培训方案属性！");
				return false;
			}
			if (coursesystemIds == "" || coursesystemIds == null) {
				window.alertx("请选择课程体系！");
				return false;
			}
//			if (ctfSetIds == "" || ctfSetIds == null) {
//				window.alertx("选择CTF题目集！");
//				return false;
//			}
//
//			if (paperIds == "" || paperIds == null) {
//				window.alertx("选择试卷！");
//				return false;
//			}



		}
	</script>
	<script type="text/javascript" src="${path}/js/common/jquery.min.js"></script>
	<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet" type="text/css" media="all">
	<%--<link rel="stylesheet" href="${path}/css/common/bootstrap.min.css" rel="stylesheet" type="text/css" media="all"/>--%>
	<link rel="stylesheet" href="${path}/css/common/bootstrap-duallistbox.css" rel="stylesheet" type="text/css"/>
	<script type="text/javascript" src="${path}/js/common/jquery.bootstrap-duallistbox.js"></script>

	<style>
		.control-label{font-weight: normal;}
		#trainprogramName{ height: 30px;}
	</style>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/resource/resourceTrainprogram/">培训方案列表</a></li>
		<li class="active"><a href="${ctx}/resource/resourceTrainprogram/form?id=${resourceTrainprogram.id}">培训方案<shiro:hasPermission name="resource:resourceTrainprogram:edit">${not empty resourceTrainprogram.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="resource:resourceTrainprogram:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="resourceTrainprogram" action="${ctx}/resource/resourceTrainprogram/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>
		<input type="hidden" name="type" id="type" value="${type}">
		<div class="control-group">
			<label class="control-label">培训方案名称：</label>
			<div class="controls">
				<form:input id="trainprogramName" name="trainprogramName" path="trainprogramName" htmlEscape="false" maxlength="64" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">培训方案属性：</label>
			<div class="controls">
				<select id="trainprogramAttribute" name="trainprogramAttribute" class="input-xlarge required">
					<c:choose>
						<c:when test="${isSuperAdmin=='false'}">
							<option value="0" selected>${fns:getDictLabel("0",'resource_trainprogram_attribute',"无")}</option>
						</c:when>
						<c:otherwise>
							<c:forEach var="attribute" items="${fns:getDictList('resource_trainprogram_attribute')}">
								<option value="${fns:getDictValue(attribute,'resource_trainprogram_attribute',"")}" <c:if test="${fns:getDictValue(attribute,'resource_trainprogram_attribute','')==resourceTrainprogram.trainprogramAttribute}">selected</c:if>>${attribute}</option>
							</c:forEach>
						</c:otherwise>
					</c:choose>


				</select>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">选择课程体系：</label>

			<div class="controls">
				<div class="container"></div>
					<%--<%@ include file="maskProgramFormTest.jsp"%>--%>
				<div class="col-lg-10 col-md-9 col-sm-9 col-xs-12">

					<select multiple="multiple" size="10" id="coursesystemIds" name="coursesystemIds" class="resetDuallist">


						<c:forEach var="resourceCoursesystem" items="${resourceCoursesystemList}">
							<option value="${resourceCoursesystem.id}"
									<c:if test="${resourceCoursesystem.isChoose=='true'}">selected</c:if>>${resourceCoursesystem.coursesystemName}</option>
						</c:forEach>

					</select>


				</div>
				<span class="help-inline"><font color="red">*</font> </span>


			</div>
		</div>
		<div class="control-group">
			<label class="control-label">选择CTF题目集：</label>

			<div class="controls">
				<div class="container"></div>
					<%--<%@ include file="maskProgramFormTest.jsp"%>--%>
				<div class="col-lg-10 col-md-9 col-sm-9 col-xs-12">

					<select multiple="multiple" size="10" id="ctfSetIds" name="ctfSetIds" class="resetDuallist">


						<c:forEach var="resourceCtfSet" items="${resourceCtfSetList}">
							<option value="${resourceCtfSet.id}"
									<c:if test="${resourceCtfSet.isChoose=='true'}">selected</c:if>>${resourceCtfSet.ctfSetName}</option>
						</c:forEach>

					</select>


				</div>

			</div>
		</div>
		<div class="control-group">
			<label class="control-label">选择试卷：</label>

			<div class="controls">
				<div class="container"></div>
					<%--<%@ include file="maskProgramFormTest.jsp"%>--%>
				<div class="col-lg-10 col-md-9 col-sm-9 col-xs-12">

					<select multiple="multiple" size="10" id="paperIds" name="paperIds" class="resetDuallist">


						<c:forEach var="resourcePaper" items="${resourcePaperList}">
							<option value="${resourcePaper.id}"
									<c:if test="${resourcePaper.isChoose=='true'}">selected</c:if>>${resourcePaper.paperName}</option>
						</c:forEach>

					</select>


				</div>

			</div>
		</div>
		<div class="control-group">
			<label class="control-label">备注信息：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="255" class="input-xxlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="resource:resourceTrainprogram:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存" onclick=" return checkValidate()"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
	<script>
		var demo1 = $('select[name="coursesystemIds"]').bootstrapDualListbox();
		$("#demoform").submit(function () {
			alert($('[name="coursesystemIds"]').val());
			return false;
		});

		var demo2 = $('select[name="ctfSetIds"]').bootstrapDualListbox();
		$("#demoform").submit(function () {
			alert($('[name="ctfSetIds"]').val());
			return false;
		});
		var demo3 = $('select[name="paperIds"]').bootstrapDualListbox();
		$("#demoform").submit(function () {
			alert($('[name="paperIds"]').val());
			return false;
		});
	</script>
</body>
</html>